<%--
 *  File:    BookSetAssign.jsp
 *  @Author: Jianni 
 *  Date:    2002/01/28
 *
 *  Copyright (C) 2000 - 2002 Oval Technologies, Inc.
 *  All rights reserved. 
 *
 *  This software is the confidential and proprietary information of Oval 
 *  Technologies, Inc. ("Confidential Information").  You shall not
 *  disclose such Confidential Information and shall use it only in
 *  accordance with the terms of the license agreement you entered into
 *  with Oval.
--%>


<%@ include file="/inc/SessionTimeout.inc"%>
<%@ page language="java" %>     
<%@ page import="java.util.*" %>
<%@ page import="org.apache.log4j.Category" %>

<%@ page contentType = "text/html;charset=UTF-8" %>
<%@ taglib uri="/WEB-INF/PageFlow.tld" prefix="PageFlow" %>
<%@ taglib uri="/WEB-INF/struts-logic.tld" prefix="logic" %>
<%@ taglib uri="/WEB-INF/oval-tag.tld" prefix="oval" %>
<%@ taglib uri="/WEB-INF/custom.tld" prefix="custom" %>

<% //--------------------------------------  setting logger --%>
<%
  	Category cat = Category.getInstance("jsp.BookSetAssign");  
%>

<% //--------------------------------------  variant and initialization --%>
<%
  	String strModuleName = "SPM";
  	String strTableName = "ovbookset";
	  String privilegeCode = "40105";
  	HashMap userInfo = (HashMap)session.getAttribute("userinfo");  	
  	if(userInfo == null)
  	  userInfo = new HashMap();
%>


<% //--------------------------------------  include files list --%>
<%@ include file="/inc/Security.inc" %>
<%@ include file="/inc/FrmDefault.inc" %>
<%@ include file="/inc/PageDefault.inc" %>
<%@ include file="/inc/LocationDefault.inc" %>


<html>
<head>
<title>BookSetAssign</title>
<PageFlow:CheckPageFlow pageName="booksetassign"/>
<%@ include file="/inc/CatchError.inc" %>
<meta http-equiv="Content-Type" content="text/html; charset=UTF-8">
<link rel="stylesheet" href="../../css/<%= strLanguageCode %>/main.css" type="text/css">
<script language="JavaScript" src="../../css/<%= strLanguageCode %>/script.js"></script>
<script language="JavaScript" src="../../js/FuncLib.js"></script>
<%@ include file="/inc/SummaryDivision.inc" %>
<% //--------------------------------------  output variant from pageflow --%>
<%

  	Vector orgSummary = (Vector)pageContext.getAttribute("orgsummary");
  	if(orgSummary == null)
  	{
    	orgSummary = new Vector();
  	}
  	cat.debug("The orgSummary is :" + orgSummary);
  
  	Vector booksets = (Vector)pageContext.getAttribute("booksets");
  	if(booksets == null)
  	{
    	booksets = new Vector();
  	}
  	cat.debug("The booksets is :" + booksets);
%>
<script>

function page_done()
{
  if(checkNull(booksetassignform))
    emptyToNull(booksetassignform);
  else
    return;
  document.booksetassignform.actionname.value = "done";
  isRunning = true;
  document.booksetassignform.submit();
}
function page_summary(actionvalue,orderbyname)
{
  var editform = summaryPrepare(booksetassignform,actionvalue,orderbyname);
  editform.action = "BookSetAssign.jsp?<%= OvalTools.randomURL() %>";
  editform.target = "_self";
  isRunning = true;
  editform.submit();  
}
</script>
</head>
<body leftmargin="0" topmargin="0" marginwidth="0" marginheight="0">
	
	<% //--------------------------------------  hidden form variant --%>
	<form name="booksetassignform" method="post" action="../../Dispatcher">
    <input type="hidden" name="pagename" value="booksetassign">
    <input type="hidden" name="actionname">   
    <input type="hidden" name="numrows" value="<%=JspHelper.filterNull( orgSummary.size() )%>">     
    
	<% //--------------------------------------  page location --%>
	<%@ include file="/inc/PageLocation.inc" %>
	
	<table width="100%" cellspacing="0" cellpadding="0" border="0">
  	<tr> 
    	<td class="summary_top"></td>
  	</tr>
  	<tr> 
    	<td> 
      		<table border="1" cellspacing="0" bordercolorlight="#999999" bordercolordark="#FFFFFF" cellpadding="0" width="100%">
        	
        	<% //--------------------------------------  summary header --%>
          	<tr class="deepblue-left"> 
            	<td class="title_center" width="80" ><%= label.getLabelName("L_OrgCode") %></td>
            	<td class="title_center" ><%= label.getLabelName("L_OrgName") %></td>
            	<td class="title_center" ><%= label.getLabelName("L_ShortName") %></td>
            	<td class="title_center" ><%= label.getLabelName("L_BusinessArea") %></td>
            	<td class="title_center" width="110" ><%= label.getLabelName("L_BooksetApplied") %></td>
          	</tr>
          	
          	<%
            	int i = 0;
            	String strClassType = new String("");   
          	%>
          	<logic:iterate id="ps" collection="<%= orgSummary %>">                      
          	<%
            	HashMap psMap = (HashMap)pageContext.getAttribute("ps"); 
            	String booksetId = (psMap.get("booksetid")==null ? "" : (psMap.get("booksetid").toString()));
            	String strIsChecked = new String("");
            	String canSelect="";
            	Integer oCount=(Integer)psMap.get("count");
            	if(oCount==null)
            	    oCount=new Integer(0);
            	int nCount=oCount.intValue();
            	if(nCount!=0)
            	{
            	    canSelect="Disabled";
            	}
            	if(i%2 == 1)
            	{
              		strClassType = "td-listrom";
            	}else{                    
              		strClassType = "none";
            	}
            	i++;     
           	%>
          	<tr onMouseOver="this.className='tr-over'" onMouseOut="this.className='<%=JspHelper.filterNull( strClassType )%>'"   class="<%=JspHelper.filterNull( strClassType )%>"> 
            	<td><a href="../ogm/OrgInfo.jsp?<%= OvalTools.randomURL() %>&orgid=<%=JspHelper.filterNull( psMap.get("orgid") )%>&languagecode=<%= strLanguageCode %>" target="content">&nbsp;<%=JspHelper.filterNull( psMap.get("orgcode") )%></a></td>
            	<td>&nbsp;<%=JspHelper.filterNull( psMap.get("orgname") )%></td>
            	<td>&nbsp;<%=JspHelper.filterNull( psMap.get("shortname") )%></td>
            	<td>&nbsp;<%=JspHelper.filterNull( psMap.get("areaname") )%></td>
                <%
                    
                    String appStatus = ((Integer)psMap.get("booksetstatus")) + "";
                    String disabled = "";
                    if (canSelect.equals("")) {
                        if (appStatus.equals("43"))
                            disabled = "disabled";
                    }
                %>
            	<td>
            		<select <%=JspHelper.filterNull( disabled)%> name="booksetid<%=JspHelper.filterNull( i-1)%>" <%=JspHelper.filterNull(canSelect)%>>
            		<option value='-1'>--------</option>
           			<logic:iterate id="bs" collection="<%= booksets %>">
		            <% 
		              HashMap mapTypes = (HashMap)pageContext.getAttribute("bs"); 
		              String strSelect = "";
		              String tempValue = ((Integer)mapTypes.get("booksetid")).toString();
		              if(tempValue.equalsIgnoreCase(booksetId))
		              {
		                strSelect = "Selected";
		              }                              
		            %>
              		<option <%=JspHelper.filterNull( strSelect )%>  value = "<%=JspHelper.filterNull( (Integer)mapTypes.get("booksetid"))%>">
              			<%=JspHelper.filterNull( mapTypes.get("booksetname") )%>
              		</option>
            		</logic:iterate> 
            		</select>
                    <script>

                    </script>
            	</td>     
            	
            	<input type="hidden" name="orgid<%=JspHelper.filterNull( i-1 )%>" value="<%=JspHelper.filterNull( psMap.get("orgid"))%>">
          	</tr>
          	</logic:iterate>                   
          
          	<% //--------------------------------------  flipping page --%>
    		<%@ include file="/inc/SummaryAction.inc" %>
        
      		</table>
      	
      		<% //--------------------------------------  page operation button --%>
      		<table width="100%" border="0" cellspacing="0" cellpadding="0">
        	<tr> 
        		<td class="summary_top" ></td>
        	</tr>
        	<tr> 
        		<td class="td_center">
        		<% if(userInfo.get("grade") != null && ((Integer)userInfo.get("grade")).intValue() == 1) {%>
        		  <a onclick="page_done()"><custom:button type="1" label="L_Finish" imgsrc="finish.gif" border="0" style="width:60"/></a>
        		<%}%>
        		</td>
        	</tr>
      		</table>
      	
 		</td>
	</tr>
	</table>
</form>
</body>
</html>


